1. /* sffbntbl.cpp by K.Tsuru */
  2. // function ID 7101 DRADIX
  3. /************************************************
  4. SFraction class
  5. It provodes the table of Bernoulli's numbers B[n].
  6. *************************************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. void BernNumTable(SNBlock <SFraction>& Bn, uint N){
  11. SNBlock <SInteger> t(2u*N+1);
  12. Bn.reserve(N);
  13. int err = (t.Error() != t.NORMAL) || (Bn.Error() != Bn.NORMAL);
  14. if(err) t[0].SetError(t[0].OUT_OF_RANGE,"BernNumTable", 7101);
  15. uint i, n;
  16. SInteger q, b1, b2, d;
  17. SLong B1, B2;
  18. for(i = 0; i <= 2*N; i++) t[i].SetZero();
  19. q = 1; t[1] = 1;
  20. for(n = 2; n <= 2*N; n++){
  21. for(i = 1; i< n; i++) IsMult(t[i], i, t[i-1]);
  22. t[n-1].SetZero();
  23. for(i = n; i >= 2; i--) IIAdd(t[i], t[i-2], t[i]);
  24. if(n % 2 == 0){
  25. IsMult(q, 4, q); // q *= 4;
  26. IsSub(q, 1, d);
  27. b2 = q*d; // b2 = q*(q-1);
  28. IsMult(t[0], n, b1);
  29. B1 = b1.ConvToDec();
  30. B2 = b2.ConvToDec(); // radix conversion
  31. Bn[n/2].Set(B1, B2);
  32. Bn[n/2].Reduce();
  33. }
  34. }
  35. }

sffbntbl.cpp : last modifiled at 2015/12/04 10:36:15(1,047 bytes)
created at 2015/12/22 16:07:29
The creation time of this html file is 2016/09/13 19:56:38 (Tue Sep 13 19:56:38 2016).